package com.chengdu.third.dao;

import com.chengdu.third.pojo.Area;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface IAreaDao {

    /**
     * 查找所有地区
     * @return
     */
    @Select("select * from area")
    public List<Area> find();

    /**
     * 根据id删除
     * @param id
     */
    @Delete("delete from area where id  = #{id}")
    public void delete(long id);

    /**
     * 根据id修改地区
     * @param area
     */
    @Update("update area set prefectures = #{prefectures},town = #{town},village = #{village} where id = #{id}")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    public void update(Area area);

    /**
     * 增加地区
     * @param area
     */
    @Insert("insert into  area(`id`,`prefectures`,`town`,`village`) values(#{id},#{prefectures},#{town},#{village})")
    public void add(Area area);

    /**
     * 根据id查询用户
     * @param id
     * @return
     */
    @Select("select * from area where id = #{id}")
    public Area getAreaById(long id);


}
